/**
 * Rubik is a for-testing-purposes simple CMS.
 * Copyright (C) 2010 Antonio Hernandez Diaz <ahdiaz@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * $Id: RolesCollection.java 8 2010-04-13 19:10:09Z ahdiaz $
 */

package net.ahdiaz.rubik.model;

import java.util.Collection;
import java.util.HashMap;

import javax.xml.bind.JAXBException;

import net.ahdiaz.rubik.model.generated.Role;
import ru.ispras.sedna.driver.DriverException;

public class RolesCollection extends SednaDocCollection {

	public RolesCollection() throws DriverException {
		super("Admin", "Roles", "/permissions/roles", "/role");
	}

	@Override
	protected Class<?> getContext() {
		return Role.class;
	}

	@Override
	protected String getPathFromObject(Object item) {
		Role role = (Role) item;
		return "/role[@uid='%uid']".replaceAll("%uid", role.getUid());
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<Role> readAll(HashMap<String, String> constraints) throws JAXBException, DriverException {
		return (Collection<Role>) super.readAll(constraints);
	}
	
	@Override
	public Collection<Role> readAll() throws JAXBException, DriverException {
		return (Collection<Role>) this.readAll(null);
	}

	@Override
	public Role readByName(String nodeName) throws JAXBException, DriverException {
		return (Role) super.readByName(nodeName);
	}

	@Override
	public Role readByUID(String uid) throws JAXBException, DriverException {
		return (Role) super.readByUID(uid);
	}

}
